<!doctype html>
<html lang="en" class="fixed">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <title>编辑学员</title>
    <link rel="apple-touch-icon" sizes="120x120" href="favicon/apple-icon-120x120.png">
    <link rel="icon" type="image/png" sizes="192x192" href="favicon/android-icon-192x192.png">
    <link rel="icon" type="image/png" sizes="32x32" href="favicon/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="favicon/favicon-16x16.png">
    <link rel="stylesheet" type="text/css"
          href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/bootstrap.min.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/animate.css/animate.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/font-awesome/css/font-awesome.css')) ?>">
    <link rel="stylesheet" type="text/css" href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/build_standalone.css')) ?>">
    <link rel="stylesheet" type="text/css"  href="<?php xcho(loadSource('/assets/plugins/bootstrap/css/build.css')) ?>">
    <link rel="stylesheet"
          href="<?php xcho(loadSource('/assets/plugins/data-table/media/css/dataTables.bootstrap.min.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/ztree/css/zTreeStyle/zTreeStyle.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/app/css/style.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/plugins/layui/css/layui.css')) ?>" media="all">
    <link rel="stylesheet" href="<?php xcho(loadSource('/app/css/app.css')) ?>">
    <link rel="stylesheet" href="<?php xcho(loadSource('/assets/css/new_main.css')) ?>">
    
    <style>
        .pagination{
            margin: 0;
        }
        ul,li,ol,li{
            list-style: none;
        }
        body{
            background: #f4f4f4;
        }
        .addCourse{
            width: 900px;
            margin: 0 auto;
            background: #fff;
        }
        .addCourse .addCourse-title{
            padding: 10px 20px;
            text-align: center;
        }
        .addCourse .addCourse-content .addCourse-cont h3{
            font-size: 12px;
            padding: 8px 10px;
            background: rgba(243,243,243,.5);
            margin-top: 0;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form{
            padding: 0 20px 20px;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form .form-row{
            margin-top: 20px;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form .form-row.linkage select{
            width: 100px;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form .form-row p{
            float: left;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form .form-row textarea{
            resize: none;
            border-radius: 5px;
            border: 1px #ccc solid;
            text-indent: 10px;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form span{
            margin-left: 40px;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form span:nth-of-type(1){
            margin-left: 0;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form select{
            width: 170px;
            border-radius: 5px;
            height: 24px;
            border:1px #ccc solid;
            font-size: 12px;
        }
        .addCourse .addCourse-content .addCourse-cont .cont-form input{
            border: 1px #ccc solid;
            /*border-radius: 5px;*/
            text-indent: 10px;
        }
        .addCourse .addCourse-content .addCourse-cont .addCourse-btn{
            width: 100%;
            height: 40px;
            padding:0 20px;
        }
        .addCourse .addCourse-content .addCourse-cont .addCourse-btn .addCourse-btn-cont{
            float: right;
        }
        .addCourse .addCourse-content .addCourse-cont .addCourse-btn .addCourse-btn-cont button{
            padding: 2px 10px;
            border:none;
            background: #1ab394;
            color:#fff;
            border-radius: 5px;
            color:#fff;
            margin-right: 10px;
            font-size: 12px;
        }
        .addCourse .addCourse-content .addCourse-cont .addCourse-btn .addCourse-btn-cont button:hover{
            background: #1ab394;
        }
        .addCourse .addCourse-content .addCourse-cont .addCourse-btn .addCourse-btn-cont button:nth-of-type(1){
            background: #fff;
            color:#888;
            border: 1px #ccc solid;
        }
    </style>
</head>

<body><?php include_once TPL_PATH . 'public/nav.phtml'; ?>

<div class="addCourse">
    <div class="addCourse-title">学员信息</div>
    <div class="addCourse-content">
        <div class="addCourse-cont">
            <h3>基本信息</h3>
            <div class="cont-form">
                <div class="form-row">
                    <span>学员名称：</span>
                    <input type="text" name="sname" value="<?php xcho($studentDetail['sname']) ?>">
<!--                    <span data-name="sname" class="hidden_area" style="color: red;padding-top: 5px;display: none"></span>-->
                    <span>联系手机：</span>
                    <input type="text" name="cellphone" value="<?php xcho($studentDetail['cellphone']) ?>" class="mobile">
                    <span data-name="cellphone" class="hidden_area" style="color: red;padding-top: 5px;display: none"></span>
                    <span>家庭座机：</span>
                    <input type="text" name="telephone" value="<?php xcho($studentDetail['telephone']) ?>">
<!--                    <span data-name="telephone" class="hidden_area" style="color: red;padding-top: 5px;display: none"></span>-->
                </div>
                <div class="form-row">
                    <span>性别<b style="visibility:hidden;"></b>：</span>
                    <select name="sex" id="">
                        <option value="">请选择</option>
                        <option value="male" <?php if($studentDetail['sex']=='male') { ?> selected="selected" <?php } ?> >男</option>
                        <option value="female" <?php if($studentDetail['sex']=='female') { ?> selected="selected" <?php } ?> >女</option>
                    </select>
                    <span>年龄<b style="visibility:hidden;"></b>：</span>
                    <input type="text" name="age" value="<?php xcho($studentDetail['age']) ?>" class="int">
                    <span>微信<b style="visibility:hidden;"></b>：</span>
                    <input type="text" name="wechat" value="<?php xcho($studentDetail['wechat']) ?>">
                </div>
                <div class="form-row">
                    <span>QQ<b style="visibility:hidden;"></b>：</span>
                    <input type="text" name="qq" value="<?php xcho($studentDetail['qq']) ?>" class="int">
                    <span>邮箱<b style="visibility:hidden;"></b>：</span>
                    <input type="text" name="email" value="<?php xcho($studentDetail['email']) ?>" class="email">
                    <span>渠道来源<b style="visibility:hidden;"></b>：</span>
                    <select name="channel_id">
                        <option value="">请选择</option>
                        <?php  foreach ($channel as $vo) { ?>
                        <option value="<?php xcho($vo['id']) ?>" <?php if($vo['cn_name']==$studentDetail['channel_name']) { ?> selected="selected" <?php } ?>><?php xcho($vo['cn_name']) ?></option>
                        <?php } ?>
                    </select>

                </div>
                <div class="form-row linkage">
                    <span>地区<b style="visibility:hidden;"></b>：</span>
                    <select id="cmbProvince" name="province"value="<?php xcho($studentDetail['province']) ?>"></select>
                    <select id="cmbCity" name="city"value="<?php xcho($studentDetail['city']) ?>"></select>
                    <select id="cmbArea" name="county"value="<?php xcho($studentDetail['county']) ?>"></select>
                    <span>家庭地址：</span>
                    <input type="text" name="home_address" value="<?php xcho($studentDetail['home_address']) ?>">
                </div>
<!--                <div class="form-row linkage">-->
<!--                    <span>备注信息：</span>-->
<!--                    <textarea name="remark" class="form-control" style="width: 700px;">--><?php //xcho($studentDetail['remark']) ?><!--</textarea>-->
<!--                </div>-->
            </div>
            <h3>学情信息</h3>
            <div class="cont-form">
                <div class="form-row">
                    <span>入学时间：</span>
                    <input type="date" name="admission_time" value="<?php xcho($studentDetail['admission_time_new']) ?>">
                    <span>当前学校：</span>
                    <input type="text" name="school" value="<?php xcho($studentDetail['school']) ?>" >
                    <span>年级<b style="visibility:hidden;"></b>：</span>

                    <select name="grade" id="">
                        <option value="">请选择</option>
                        <?php foreach ($grade as $gr) { ?>
                            <option value="<?php xcho($gr['dict_value']) ?>" <?php if($gr['dict_value']==$studentDetail['grade']) { ?> selected="selected" <?php } ?> ><?php xcho($gr['cn_name']) ?></option>
                        <?php } ?>

                    </select>
                </div>
            </div>
            <h3>相关信息</h3>
            <div class="cont-form">
                <div class="form-row">
                    <div class="row">
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">亲戚名称：</span>
                                <?php if(!empty($stu_relation0)) { ?>
                                    <input type="text" name="relation1" value="<?php xcho($stu_relation0['relation']) ?>" class="form-control" placeholder="亲戚名称">
                                    <input type="hidden" name="relaion1_id" value="<?php xcho($stu_relation0['id']) ?>">
                                <?php }else { ?>
                                    <input type="text" name="relation1" value="" class="form-control" placeholder="亲戚名称">
                                    <input type="hidden" name="relaion1_id" value="">
                                <?php } ?>

                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">亲戚姓名：</span>
                                <?php if(!empty($stu_relation0)) { ?>
                                    <input type="text" name="full_name1" value="<?php xcho($stu_relation0['full_name']) ?>" class="form-control" placeholder="亲戚姓名">
                                <?php }else{ ?>
                                    <input type="text" name="full_name1" value="" class="form-control" placeholder="亲戚姓名">
                                <?php } ?>

                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">亲戚手机：</span>
                                <?php if(!empty($stu_relation0)) { ?>
                                    <input type="text" name="re_cellphone1" value="<?php xcho($stu_relation0['cellphone']) ?>" class="form-control" placeholder="亲戚手机" class="mobile">
                                <?php }else { ?>
                                    <input type="text" name="re_cellphone1" value="" class="form-control" placeholder="亲戚手机" class="mobile">
                                <?php } ?>

                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-row">
                    <div class="row">
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">亲戚名称：</span>
                                <?php if(!empty($stu_relation1)) { ?>
                                    <input type="text" name="relation2" value="<?php xcho($stu_relation1['relation']) ?>" class="form-control" placeholder="亲戚名称">
                                    <input type="hidden" name="relaion2_id" value="<?php xcho($stu_relation1['id']) ?>">
                                <?php }else { ?>
                                    <input type="text" name="relation2" value="" class="form-control" placeholder="亲戚名称">
                                    <input type="hidden" name="relaion2_id" value="">
                                <?php } ?>


                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">亲戚姓名：</span>
                                <?php if(!empty($stu_relation1)) { ?>
                                    <input type="text" name="full_name2" value="<?php xcho($stu_relation1['full_name']) ?>" class="form-control" placeholder="亲戚姓名">
                                <?php }else { ?>
                                    <input type="text" name="full_name2" value="" class="form-control" placeholder="亲戚姓名">
                                <?php } ?>

                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="input-group">
                                <span class="input-group-addon">亲戚手机：</span>
                                <?php if(!empty($stu_relation1)) { ?>
                                    <input type="text" name="re_cellphone2" value="<?php xcho($stu_relation1['cellphone']) ?>" class="form-control" placeholder="亲戚手机" class="mobile">
                                <?php }else{ ?>
                                    <input type="text" name="re_cellphone2" value="" class="form-control" placeholder="亲戚手机" class="mobile">
                                <?php } ?>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <h3>跟进信息</h3>
            <div class="cont-form">
                <div class="form-row">
                    <span>意向状态：<b style="visibility:hidden;"></b>：</span>
                    <select name="intention">
                        <option value="">请选择</option>
                        <?php foreach ($intentionList as $in) { ?>
                        <option value="<?php xcho($studentDetail['intention']) ?>" <?php if($studentDetail['intention']==$in['dict_value']) { ?> selected="selected" <?php } ?> ><?php xcho($in['cn_name']) ?></option>
                        <?php } ?>
                    </select>

                    <span>学员类型：</span>
                    <select name="is_test" id="">
                        <option value="">请选择</option>
                        <?php foreach ($is_test as $is) { ?>
                        <option value="<?php xcho($studentDetail['is_test']) ?>" <?php if($studentDetail['is_test']==$is['dict_value']) { ?> selected="selected" <?php } ?> ><?php xcho($is['cn_name']) ?></option>
                        <?php } ?>
                    </select>
                </div>
            </div>
            <h3>同步信息</h3>
            <div class="cont-form">
                <div class="form-row">
                    <span>天王星学员ID：</span>
                    <input type="text" placeholder="<?php xcho($studentDetail['twx_id']) ?>" name="twx_id" value="<?php xcho($studentDetail['twx_id']) ?>" class="int">
                    <span>官网学员ID：</span>
                    <input type="text" placeholder="<?php xcho($studentDetail['gw_id']) ?>" name="gw_id" value="<?php xcho($studentDetail['gw_id']) ?>" class="int">
                    <span>学员账号：</span>
                    <input type="text" placeholder="<?php xcho($studentDetail['gw_account']) ?>" name="gw_account" value="<?php xcho($studentDetail['gw_account']) ?>">
                </div>
                <div class="form-row">
                    <span>学员密码：</span>
                    <input type="text" placeholder="<?php xcho($studentDetail['gw_password']) ?>" name="gw_password" value="<?php xcho($studentDetail['gw_password']) ?>">
                </div>
                <div class="form-group">
                    <label>推荐人：</label>
                    <input type="text" class="form-control" placeholder="<?php xcho($studentDetail['introducer_id']) ?>" name="introducer_id" value="<?php xcho($studentDetail['introducer_id']) ?>" class="int">
                </div>
            </div>
            <h3>系统信息</h3>
            <div class="cont-form">
                <div class="form-row">

                    <span>CC负责人：</span>
                    <select name="cc_id" id="">
                        <option value="">请选择</option>
                        <?php foreach ($aCcList as $cc) { ?>
                            <option value="<?php xcho($cc['id']) ?>" <?php if($cc['id']==$studentDetail['cc_id']){ ?>selected="selected" <?php } ?> ><?php xcho($cc['user_name']) ?></option>
                        <?php } ?>
                    </select>
                    <span>TMK负责人：</span>
                    <select name="tmk_id" id="">
                        <option value="">请选择</option>
                        <?php foreach ($aTmkList as $tmk) { ?>
                            <option value="<?php xcho($tmk['id']) ?>" <?php if($tmk['id']==$studentDetail['cc_id']){ ?>selected="selected" <?php } ?> ><?php xcho($tmk['user_name']) ?></option>
                        <?php } ?>
                    </select>
                </div>
                    <div class="col-xs-4">
                        <div class="basemess-cont">
                            <p>联系备注：</p>
                            <textarea name="remark" id="" cols="100" rows="3"><?php xcho($studentDetail['remark']) ?></textarea>
                        </div>
                    </div>
            </div>
            <div class="addCourse-btn">
                <div class="addCourse-btn-cont">
                    <button id="cancel">取消</button>
                    <button id="save">确定</button>
                </div>
            </div>
        </div>
    </div>
</div>
<input type="hidden" name="save_user" value="<?php xcho($saveStudent) ?>"/>
<input type="hidden" name="uid" value="<?php xcho($uid) ?>"/>
<script src="<?php xcho(loadSource('/assets/plugins/jquery/jquery.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/bootstrap/js/bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/data-table/media/js/jquery.dataTables.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/data-table/media/js/dataTables.bootstrap.min.js')) ?>"></script>
<script
        src="<?php xcho(loadSource('/assets/plugins/data-table/extensions/Responsive/js/dataTables.responsive.min.js')) ?>"></script>
<script
        src="<?php xcho(loadSource('/assets/plugins/data-table/extensions/Responsive/js/responsive.bootstrap.min.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.core.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/plugins/layui/layui.all.js')) ?>" charset="utf-8"></script>
<script type="text/javascript" src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.excheck.js')) ?>"></script>
<script type="text/javascript" src="<?php xcho(loadSource('/assets//plugins/ztree/js/jquery.ztree.exedit.js')) ?>"></script>
<script type="text/javascript"
        src="<?php xcho(loadSource('/assets/js/validate.js')) ?>"></script>
<script src="<?php xcho(loadSource('/assets/js/city.js')) ?>"></script>
<script>
    $(function () {
        $("#cancel").on("click",function () {
            window.parent.$('#index_tabs').tabs('close','编辑学员');
        });
        console.log("<?php xcho($studentDetail['city']) ?>");
        addressInit('cmbProvince', 'cmbCity', 'cmbArea',"<?php xcho($studentDetail['province']) ?>","<?php xcho($studentDetail['city']) ?>","<?php xcho($studentDetail['county']) ?>");
        $("#save").on("click", function () {
            var param = {};
            var stu_relation = {};
            param.id = $("input[name='uid']").val();
            param.sname = $("input[name='sname']").val();
            param.cellphone = $("input[name='cellphone']").val();
            param.telephone = $("input[name='telephone']").val();
            param.sex = $("select[name='sex']").val();
            param.age = $("input[name='age']").val();
            param.wechat = $("input[name='wechat']").val();
            param.qq = $("input[name='qq']").val();
            param.email = $("input[name='email']").val();
            param.channel_id = $("select[name='channel_id']").val();
            param.province = $("select[name='province']").val();
            param.city = $("select[name='city']").val();
            param.county = $("select[name='county']").val();
            param.home_address = $("input[name='home_address']").val();
            param.admission_time = $("input[name='admission_time']").val();
            param.school = $("input[name='school']").val();
            param.grade = $("select[name='grade']").val();
            param.intention = $("select[name='intention']").val();
            param.is_test = $("select[name='is_test']").val();
            param.twx_id = $("input[name='twx_id']").val();
            param.gw_id = $("input[name='gw_id']").val();
            param.gw_account = $("input[name='gw_account']").val();
            param.gw_password = $("input[name='gw_password']").val();
            param.cc_id = $("select[name='cc_id']").val();
            param.tmk_id = $("select[name='tmk_id']").val();
            param.remark = $("textarea[name='remark']").val();
            param.introducer_id = $("input[name='introducer_id']").val();

            var reg_phone = /^1[3|4|5|7|8][0-9]{9}$/; //验证规则
            var re_cellphone1=$("input[name='re_cellphone1']").val();
            var flag1 = reg_phone.test(re_cellphone1);
            if(re_cellphone1!=''&&flag1==false){
                alert('亲属手机号码格式不正确');
                return false;
            }

            var re_cellphone2=$("input[name='re_cellphone2']").val();
            var flag2 = reg_phone.test(re_cellphone2);
            if(re_cellphone2!=''&&flag2==false){
                alert('亲属手机号码格式不正确');
                return false;
            }

            stu_relation = {
                0:{
                    id:$("input[name='relaion1_id']").val(),
                    relation:$("input[name='relation1']").val(),
                    full_name:$("input[name='full_name1']").val(),
                    cellphone:$("input[name='re_cellphone1']").val()
                },
                1:{
                    id:$("input[name='relaion2_id']").val(),
                    relation:$("input[name='relation2']").val(),
                    full_name:$("input[name='full_name2']").val(),
                    cellphone:$("input[name='re_cellphone2']").val()
                }
            }

            param.stu_relation = stu_relation;
            $.ajax({
                url: $("input[name='save_user']").val(),
                type: 'post',
                data:param,
                dataType: 'json',
                success: function (data) {
                    console.log(data);
                    if(data.success == 1){
                        location.href = "/student/pool/index";
                    }else{
                        console.log(data.errors);
                        var errors = data.errors;
                        for(var i in errors){
//                            $("span.hidden_area").css("display","none")
                            $("span.hidden_area").each(function () {
                                console.log($(this).attr("data-name")==i);
                                if($(this).attr("data-name")==i){
                                    $(this).css("display","inline");
                                    $(this).html(errors[i].message);
                                }
                            })
                        }
                    }
                },
                complete:function(){

                },
                error: function () {

                }
            });
        });
    });
</script>
<?php include_once TPL_PATH . 'public/foot_script.phtml'; ?>
<button id="top" style="height: 50px;width: 50px;"></button></body>

</html>
